package com.lottery.game.core.modules.mapper;

import com.lottery.game.core.modules.entity.app.BetRecordVO;
import com.lottery.game.core.modules.entity.game.GameApiLog;
import com.lottery.game.core.modules.entity.user.BetLimit;
import com.lottery.game.core.modules.entity.user.GameIssue;
import com.lottery.game.core.modules.entity.user.HuiShui;
import com.lottery.game.core.modules.entity.user.SpecialOdds;
import com.lottery.game.core.modules.entity.user.UserBlncDetail;

import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 游戏用户DAO接口
 * @author chenye
 * @version 2018-03-25
 */
public interface BetDao{
	/**
	 * 通过游戏期号获取游戏场次
	 * @param issue  开奖期号
	 * @return
	 */
	public List<Map<String, Object>> getGamelistByIssue(@Param("issue") String issue);
	/**
	 * 通过游戏场次id 获取到所有参加游戏的人，和押注数据
	 * @param gameid
	 * @return
	 */
	 List<Map<String, Object>> getUserListByGameid(@Param("gameid") String gameid);

	 Map<String, Object> getOddbyRoomNumber(@Param("roomNumber") String room_id);
	//public void saveUserMoney(@Param("money")BigDecimal money,@Param("id")String id);

	 void addUserMoney(@Param("money") BigDecimal money, @Param("id") String id);
	 void subUserMoney(@Param("money") BigDecimal money, @Param("id") String id);

	 BigDecimal queryUserMoney(@Param("id") String id);

	 void addBalanceDetail(UserBlncDetail userBlncDetail);

	 void insertBalanceDetailByList(List<UserBlncDetail> list);

	 void addGameIssue(GameIssue gameIssue);

	 List<GameIssue> queryGameIssue(GameIssue gameIssue);

	 List<GameIssue> queryRoomGameIssueHis(@Param("roomId") String roomId,
          @Param("start") int start, @Param("size") int size);

	 void updateGameIssueError();

	 void updateGameIssueStatus(@Param("status") String status,
          @Param("issue") String currentIssue, @Param("note") String note);

	 void updateGameIssueClose(@Param("status") String status,
          @Param("issue") String currentIssue);

	 void updateGameIssueResult(@Param("status") String status,
          @Param("issue") String currentIssue, @Param("resultStr") String resultStr, @Param(
          "note") String note);

	//批量操作
	 void addGameIssueBatch(List<GameIssue> list);
	//public void addBalanceDetailBatch(List<UserBlncDetail> blncChangeList);
	 void saveUserMoneyBatch(List<UserBlncDetail> blncChangeList);

	void saveUserMoney2(UserBlncDetail blncChangeList);

	void updateUserBalance(BigDecimal changeAmt,String userId);

	 List<UserBlncDetail> queryUserBlncDetail(@Param("userId") String userId,
          @Param("start") int start, @Param("size") int size,
          @Param("startDate") String startDate, @Param("endDate") String endDate,
          @Param("type") String type);

	//下注相关余额变化明细查询
	 List<UserBlncDetail> queryUserBlncDetailWithBet(@Param("userId") String userId,
          @Param("start") int start, @Param("size") int size,
          @Param("startDate") String startDate, @Param("endDate") String endDate);
	//充值提现相关余额变化明细查询
	 List<UserBlncDetail> queryUserBlncDetailWithInOut(@Param("userId") String userId,
          @Param("start") int start, @Param("size") int size,
          @Param("startDate") String startDate, @Param("endDate") String endDate);


	 List<SpecialOdds> querySpecialOdds(SpecialOdds specialOdds);

	 BigDecimal queryCurrentIssueBetTotleAmt(@Param("gameId") String gameId,
          @Param("userId") String userId);

	 BigDecimal queryCurrentIssueTypeBetAmt(@Param("gameId") String gameId,
          @Param("userId") String userId, @Param("betStr") String betStr);

	 List<BetLimit> queryLimitByRoomNumber(@Param("roomnumber") String roomnumber);
	 List<HuiShui> getHuiShui(@Param("userId") String userId,
            @Param("roomnumber") String roomnumber, @Param("start") int start, @Param("size") int size);
	 String getHuishuiGuiZe();

	 void insertApiLog(GameApiLog apiLog);
	 List<GameApiLog> queryGameApiLogByIssueApi(GameApiLog apiLog);

	 void tryUpdateIssueOpenTime(GameIssue gameIssue);
	/**
	 * @Description 通过用户,状态,时间,种类查询交易记录
	 * @param:
	 * @Return
	 * @Date 2019/4/25_9:07
	 */
     List<BetRecordVO> findRecodeList(@Param("userId") String id,@Param("startDate") String startDate,
									  @Param("endDate") String endDate, @Param("betType") String betType,
	  								 @Param("recordStatus") String recordStatus);
	/**
	 * @Description 投注记录统计
	 * @param:
	 * @Return
	 * @Date 2019/5/13_9:07
	 */
    Map<String, Object> getBetSum(@Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);

     public void updateOpenTimeByExpect(@Param("expect") Integer expect, @Param("openTime") Date openTime);

}
